home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
VideoToolbox 96.06.15
/
VideoToolboxSources
/
ChooseScreen.c
< prev
next >
Wrap
Text File
|
1995-01-07
|
2KB
|
75 lines
/*
ChooseScreen.c
Displays a screen number on every screen, and accepts the typed selection from
the user, using the argument value as the default. No check is made for
validity of the default or the reply.
screen=1;
screen=ChooseScreen(screen,"Which screen?");
HISTORY:
9/5/94 dgp removed assumption in printf's that int==short.
10/2/94 dgp added question argument.
1/5/95 dgp made compatible with Universal Headers 2.
*/
#include "VideoToolbox.h"
#if UNIVERSAL_HEADERS
#include <LowMem.h>
#else
extern void LMSetGhostWindow(WindowPeek GhostWindowValue);
#define LMSetGhostWindow(GhostWindowValue) ((* (WindowPeek *) 0x0A84) = (GhostWindowValue))
#endif
int ChooseScreen(int screen,const char *question)
{
short i,fontNumber,textSize;
Rect r;
GDHandle device=NULL,oldDevice=NULL;
WindowPtr window=NULL,oldWindow=NULL,windows[MAX_SCREENS];
unsigned char string[16]="\p0";
char str[32];
FontInfo fontInfo;
long ticks;
oldDevice=GetGDevice();
SetGDevice(GetMainDevice());
GetPort(&oldWindow);
ticks=TickCount();
for(i=0;i<MAX_SCREENS;i++){
device=GetScreenDevice(i);
if(device == NULL)break;
SetRect(&r,0,0,160,160);
CenterRectInRect(&r,&(*device)->gdRect);
string[1]='0'+i;
windows[i]=NewWindow(NULL,&r,string,TRUE,plainDBox,(WindowPtr) -1L,0,0);
SetPort(windows[i]);
if(i==0)GetFNum("\pChicago",&fontNumber);
TextFont(fontNumber);
textSize=128;
TextSize(textSize);
if(i==0)GetFontInfo(&fontInfo);
SetRect(&r,0,0,StringWidth(string),fontInfo.ascent);
CenterRectInRect(&r,&windows[i]->portRect);
MoveTo(r.left,r.bottom);
DrawString(string);
}
#if UNIVERSAL_HEADERS>1
LMSetGhostWindow((WindowRef)windows[0]); // doesn't work; don't know why.
#else
LMSetGhostWindow((WindowPeek)windows[0]); // doesn't work; don't know why.
#endif
SetPort(oldWindow);
SetGDevice(oldDevice);
ticks=ticks+50-TickCount();
if(ticks>0)Delay(ticks,&ticks);
printf("%s (%d):",question,screen);
gets(str);
sscanf(str,"%d",&screen);
for(i=0;i<MAX_SCREENS;i++){
device=GetScreenDevice(i);
if(device==NULL)break;
DisposeWindow(windows[i]);
}
return screen;
}